package com.kgame5.xtank3d.effect.myemitters {
	import com.kgame5.xtank3d.resource.ResourceManagerX;
import kgame5.k3d.core.math.Vector3D;
import kgame5.k3d.core.obj3d.node3d.Node3D;
import kgame5.k3d.pars.myflint.geom.Vector3DFlint;
import kgame5.k3d.pars.myflint.zones.SphereZone;
import kgame5.k3d.pars.myflint.zones.Zone3D;
import kgame5.kgu.spacial.SpacialManager;
import kgame5.kmath.MathDG;

import com.kgame5.xtank3d.effect.MyEmitter;

import flash.utils.Dictionary;

/**
 * @author kk
 * 坦克死亡碎片爆炸
 * 注意加速度要用米/秒*秒!
 * 
 * 坦克的模型是事先在外部做好的，都是位于wrold的下层，
 * 使用的时候把各个模型的值赋值给particle3D.position即可
 * 
 * md_head
 * md_chest
 * md_waist
 * md_wheel:1,2,3,4,5,6
 */
public class TankDieChipsEmitter extends MyEmitter{
	
	//power是力量
	public function TankDieChipsEmitter(power:int=40) {
		
		var c:Vector3D=new Vector3D(0,-40,0);//爆炸中心
		
		var pZone:Zone3D=new SphereZone(Vector3DFlint.ZERO, 28);
		var rZone:Zone3D=new SphereZone(Vector3DFlint.ZERO, 180);
		var rvZone:Zone3D=new SphereZone(Vector3DFlint.ZERO, 20,10);
		
		var arr:Array=[];
	
		for(var i:int=0;i<4;i++){
			arr.push(ResourceManagerX.getInstance().getTankDieChip());
		}
		arr.push(ResourceManagerX.getInstance().getTankHurtChip());
		arr.push(ResourceManagerX.getInstance().getTankHurtChip());
		
		
		for each(var md:Node3D in arr){
			//位置
			var pp:Vector3DFlint=pZone.getLocation();
			md.x=pp.x;
			md.y=pp.y;
			md.z=pp.z;
			//速度
			var v:Vector3D=md.posi.clone();
			v.sub(c);
			var speedMag:int=MathDG.linearFunc(v.magnitude(),power,128) / 1;//md.hardVO.weight;//a=F/m;
			v.normalize();
			v.mul(speedMag);
		
			md.velo.copy(v);
			
			//加速度
			md.ti.hardVO.v3d_a.y= SpacialManager.G;
			
			//旋转
			md.ti.hardVO.v3d_r=rZone.getLocation().toVector3D();
			
			md.ti.hardVO.v3d_rv=rvZone.getLocation().toVector3D();
			
			//生命
			md.life=-1;//落地
		
			//--添加到世界
			md_g.addChild(md);
		}
	}
	
}//end of class
}